public class test2 {
    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5};
        //实现交换数据
        int left = 0;
        int right = arr.length - 1;
//        while(left < right){
//            int tmp = arr[left];
//            arr[left] = arr[right];
//            arr[right] = tmp;
//            left++;
//            right--;
//        }

        for(int i = 0 , j = arr.length - 1 ;i < j ;i++,j--){
            int tmp = arr[left];
            arr[left] = arr[right];
            arr[right] = tmp;
            left++;
            right--;
        }
        for(int i = 0;i < arr.length ;i++){
            System.out.print(arr[i] + " ");
        }
    }
}
